package com.wxm.pattern.register;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Description TODO
 * @author: wxm
 * @date: 2019/6/14 15:05
 * @version: 1.0
 */
public class RegisterSingleton {

    private RegisterSingleton(){

    }

    private static Map<String,Object> map = new ConcurrentHashMap<String,Object>();

    public static Object getInstance(String clazz) throws ClassNotFoundException {
        if(map.containsKey(clazz)){
            return map.get(clazz);
        }else{
            Object o = Class.forName(clazz);
            map.put(clazz,o);
            return o;
        }
    }
}
